package com.frame.auth.resource.security.handler;

import com.frame.common.core.util.ResponseUtils;
import com.frame.common.tools.result.ResultCode;
import com.frame.common.tools.result.ServiceResult;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 注销成功
 *
 * @auther zhangwj
 * @date 2021/3/18 下午1:48
 */
public class GoLogoutSuccessHandler implements LogoutSuccessHandler {

    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest,
                                HttpServletResponse httpServletResponse,
                                Authentication authentication) throws IOException, ServletException {
        ResponseUtils.writeJson(httpServletResponse, ServiceResult.getFailureResult(ResultCode.LOGOUT_SUCCESS));
    }
}
